﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Itop.YHPC;
using Itop.YHPC.Model;
using Itop.YHPC.controller;

public partial class changpwd : BasePage {
    protected override void Page_Load(object sender, EventArgs e) {
        base.Page_Load(sender, e);
    }
    
    protected void Button1_Click(object sender, EventArgs e) {
        
        string pwd0 = pwd1.Text.ToString();
        string UserName = GetUser().LoginID;
        //string Pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text.ToString(),"Md5");
        string Pwd = pwd2.Text.ToString();
        string yzm = TextBox3.Text.ToString();
        if (yzm.ToUpper() == Session["CheckCode"].ToString()) {
            sysuser user = Global.SqlMapper.GetOne<sysuser>(string.Format("where loginid='{0}' and pwd='{1}'", UserName, pwd0));
            
                if (user == null) {
                    util.Message(this, "警告:旧密码输入错误啦！");
                } else {
                    user.pwd = Pwd;
                    Global.SqlMapper.Update<sysuser>(user);
                    util.Message(this, "密码修改成功！请记住新密码："+Pwd);
                    //Response.Redirect("~/index.aspx");
                }
            
        } else {
            util.Message(this, "提示:\\n验证码错误!");

        }
    }
}

